<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <link rel="stylesheet" type="text/css" href="../css/popup.css"/> 
            <link rel="stylesheet" type="text/css" href="../css/kapiform.css"/> 

            <script type="text/javascript" language="javascript">
                var open_cur = 0;
                $j = jQuery.noConflict();
                var redirect ="";
                $j(document).ready(function(){
                    $j('#fancybox-close').addClass('fancyboxClose');
                                
                    
                    var letter = 8;
                    //                    $j(".messagesms").live('keypress',function(e) {
                    //                       
                    //                        if(e.charCode >= 48 ){
                    //                           letter--;
                    //                           alert(letter);
                    //                            if(letter < 1){
                    //                               return false;
                    //                            } 
                    //                        }
                    //                               // return false;
                    //                    });
                    $j('.sendsmsexe').live('click',function(){
                        var phone = $j(this).attr('lang');
                       
                        message  = $j('.messagesms').val();      
                        var pn100  = $j('#pn100').val();
                        var mv306  = $j('#mv306').val();
                        empString  = $j('#empString').val();
                        var mv302=$j('.mv302').val();
                        var mv305=$j('.mv305').val();
                        //  data:image/png;base64,
                        // var image64 = dataURL.replace(/data:image\/png;base64,/, '');
                        var temp  = phone+','+$j('.addphone').val();
                        if(mv302.length > 5){
                            temp.split(',').each(function(e){
                                if(e.length>9){
                                    $j.ajax({
                                        url: "http://center.fibosms.com/Service.asmx/SendSMS?",
                                        type: "POST",
                                        data: {clientNo:"CL7793", clientPass:"ntis@sale@1234", phoneNumber:e, smsMessage:message, smsGUID:1,serviceType:4684},
                                        dataType: "json",
                                        beforeSend: function(x) {
                                                       
                                            if (x && x.overrideMimeType) {
                                                x.overrideMimeType("application/j-son;charset=UTF-8");
                                                //  $j('.returnss').text(x);
                                            }
                                        },
                                        complete: function(data){
                                                
                                            //                                            $j.post('actionM300.jsp?action=sendSMS&pn100='+pn100+'&phone='+phone+'&mv302='+mv302+'&mv305='+mv305+'&mv306='+mv306,function(data){
                                            //                                               
                                            //                                                if(data !=null){
                                            //                                                    $j('.success').text('GỬI THÀNH CÔNG !');
                                            //                                                }
                                            //                                            });
                                        },
                        						
                                        success: function( strData ){
                                                        
                                        }
                                    });							
                              
                                }
                      
                            });
                            $j.post('actionM300.jsp?action=sendSMS&pn100='+pn100+'&phone='+phone+'&mv302='+mv302+'&mv305='+mv305+'&mv306='+mv306,function(data){
                                               
                                if(data !=null){
                                    $j('.success').text('GỬI THÀNH CÔNG !');
                                }
                            });
                       
                        }else{
                            $j('.success').text('VUI LÒNG KIỂM TRA LẠI NỘI DUNG !');
                        }                          
                    

                    });
                  
          
                    
                    
                   
                });
            </script>
            <style type="text/css">
                .fancyboxClose{
                    display: none !important;
                }
                .template_input{
                    float: left !important;
                    margin-left: 68px !important;
                    margin-top: 5px;
                }
                .edit_form_right {
                    float: left;
                    height: 230px;
                    overflow: auto;
                    width: 310px !important;
                }
                .del{
                    float:left;
                    margin-top:9px;
                }
                .fields_input span img{
                    float:left;
                    width:15px;
                    height:15px;
                }
                .fields_input{
                    margin-top: 6px!important;
                    margin-left:10px !important;
                    width: 97% !important;
                }


                .form_item_content{
                    margin-left: 0px !important;
                }
                .contentsms textarea{
                    float:left;
                    width:400px;
                    height: 90px;
                }
                .contentsmsmd textarea{
                    float:left;
                    width:400px;
                    height: 60px;
                }
                .contentsms{
                    padding-bottom: 3px;
                }
                .filterbg{
                    float:left;
                    background: #D1E1F1;
                    width:100%;
                    padding-top:4px;
                    padding-bottom: 10px;
                }
                .hten{
                    float: left;
                    font-weight: bold;
                    margin-top: 4px;
                    text-transform: uppercase;

                }
                .success{
                    color: red;
                    float: left;
                    margin-left: 200px;
                    position: relative;
                    text-align: center;
                    text-transform: uppercase;
                    margin-top:10px;
                    width:200px;

                }
                .note{
                    float: left;
                    font-style: italic;
                    left: 0;
                    margin-left: 136px;
                    margin-top: 31px;
                    position: absolute;
                    width: 520px;
                }
            </style>
        </head>

        <body style=" float:left; width:auto; height:auto; margin:0px;">
            <f:loadBundle basename="#{environmentSession.localizationSource}" var="locale"/>

            <h:inputHidden value="#{CustomerBean.pn100}" id="pn100"/>
            <h:inputHidden value="#{CustomerBean.mv306}" id="mv306"/>


            <a4j:form>                
                <div class="popup" style="height:400px; width:600px">
                    <div class="popup-header">
                        <div class="title"><h:outputText value="SEND SMS"/></div>
                    </div>
                    <div class="popup-content">
                        <div class="main_content">
                            <div class="form_item_content" style="display: block;">
                                <div class="filterbg">
                                    <div class="fields_input">
                                        <label><h:outputText value="Người nhận "/>:</label> 
                                        <h:outputText value="#{CustomerBean.hoten} (#{CustomerBean.nv961})" style="width:400px;height:28px;margin-top:4px;font-weight:bold;float:left;"/>                                         

                                    </div>
                                    <h:outputText styleClass="note" value="Chú ý mỗi số điện thoại cách nhau dấu phẩy (0932413788,01267175275)"/>
                                    <div class="fields_input">
                                        <label><h:outputText value="(+) " style="font-weight:bold;"/></label>
                                        <h:inputText value="" styleClass="hten addphone" style="width:400px;height:23px;"/>


                                    </div>

                                </div>
                                <div class="fields_input contentsms">
                                    <label><h:outputText value="Nội dung"/></label>
                                    <h:inputTextarea value="" styleClass="messagesms mv302"/>
                                </div>
                                <div class="filterbg">
                                    <div class="fields_input contentsmsmd">
                                        <label><h:outputText value="Mục đích:"/></label>
                                        <h:inputTextarea value="" styleClass="mv305" />
                                    </div>
                                </div>
                            </div>
                            <div class="success"></div>
                        </div>

                    </div>
                    <div class="popup-footer">

                        <div class="buttonsave close loadpage" onclick="closePopup();" lang="<h:outputText value="#{CustomerBean.pagereload}?type=#{CustomerBean.ni104}&pk400=#{CustomerBean.fk400}&dayss=#{CustomerBean.dayss}"/>" style="margin-right: 66px;" ><span><h:outputText value="#{locale.close}"/></span></div>
                        <a4j:commandButton  onclick="showPleaseWait();" oncomplete="hidePleaseWait();" value="#{locale.save}" styleClass="buttonsave sendsmsexe" lang="#{CustomerBean.nv961}">

                        </a4j:commandButton>

                    </div>
                </div>
            </a4j:form>
            <rich:modalPanel id="ajaxLoadingModalBox" minHeight="30" minWidth="40"
                             height="30" width="40" zindex="2000">
                <h:outputText value="#{locale.please_wait}" styleClass="startDummer"></h:outputText>
            </rich:modalPanel>
        </body>
    </html>
    <script type="text/javascript">
        function closePopup(){
            page =  $j('.loadpage').attr('lang')
            //            alert(page);
            //            parent.$.fancybox.close();
            window.location =page;
            //       parent.jQuery.fancybox.close();
            //alert('aaa');
        }
        $j(document).ready(function(){
            
            yhight = ($j('.popup').height()-90)+"px" ;
            $j('.main_content').css('height',yhight );
            $j('.popup-content').css('height',yhight );
        });
    </script>
</f:view>